package com.atguigu.tingshu.order.service.impl;

import com.atguigu.tingshu.model.order.LocalMsg;
import com.atguigu.tingshu.order.mapper.LocalMsgMapper;
import com.atguigu.tingshu.order.mapper.OrderInfoMapper;
import com.atguigu.tingshu.order.service.MqOpsService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author：yyj
 * @Package：com.atguigu.tingshu.order.service.impl
 * @Project：tingshu_parent240829
 * @name：MqOpsServiceImpl
 * @Date：2025/2/13 10:16
 * @Filename：MqOpsServiceImpl
 */
@Service
public class MqOpsServiceImpl implements MqOpsService {
    @Autowired
    private LocalMsgMapper localMsgMapper;
    @Autowired
    private OrderInfoMapper orderInfoMapper;

    @Override
    public void updateLocalMsg(String content) {
        LambdaQueryWrapper<LocalMsg> wrapper = new LambdaQueryWrapper<LocalMsg>().eq(LocalMsg::getMsgContent, content);
        LocalMsg localMsg = localMsgMapper.selectOne(wrapper);
        if (localMsg!=null){
            localMsg.setStatus(1);
            localMsgMapper.updateById(localMsg);
        }
    }

    @Override
    public void cancelOrder(String orderNo) {
        orderInfoMapper.cancelOrder(orderNo);
    }
}